define(function(require){
	var $=require("jq");
	var Dialog=require("pz_use_dialog.js");
	var allowPointTransform = $('#allowPointTransform').val();
	if(allowPointTransform == 'false'){
		_alert('存在待转换的积分');
		return;
	}
	
	function _alert(msg){
		var tips=new Dialog({
			  type:"confirm",
			  text:"系统提示",
			  tipsText:msg,
			  buttonSureText:"知道了", 
			  buttonCancelText:"关闭", 
			  callBack:function(){         //回调函数
			  },
			  cancelCallBack:function(){
			  },
			  mask:0.8,
			  isDrag:true                //开起拖动
		});
	}
	
	$('#integrationSubmit').bind('click',function(event){
  		var changeAmount = $('#integration').val();
  		var param = {};
  		param['amount'] = changeAmount;
  		
  		$.getJSON("/vipCenter/userPointTransfer.do",param,function(data){
  			var loginError = data.loginError;
  			var success = data.success;
  			var message = data.message;
  			var toUrl = data.toUrl;
  			
  			if(loginError == 1){
  				var tips=new Dialog({
  				  type:"confirm",
  				  text:"系统提示",
  				  tipsText:msg,
  				  buttonSureText:"去登陆", 
  				  buttonCancelText:"关闭", 
  				  callBack:function(){         //回调函数
  					  window.location.href=toUrl;
  				  },
  				  mask:0.8,
  				  isDrag:true                //开起拖动
  				});
  			}else if(success == 0){
  				var tips=new Dialog({
    				  type:"alert",
    				  text:"系统提示",
    				  tipsText:message,
    				  buttonCancelText:"关闭", 
    				  mask:0.8,
    				  isDrag:true                //开起拖动
				});
  			}else if(success == 1){
  				var tips=new Dialog({
  				  type:"alert",
  				  text:"系统提示",
  				  tipsText:message,
  				  buttonCancelText:"关闭", 
  				  mask:0.8,
  				  isDrag:true                //开起拖动
				});
  			}
  		});
	});
	
	$('#integrationExtSubmit').bind('click',function(event){
		var changeAmount = $('#integration').val();
  		var param = {};
  		param['amount'] = changeAmount;
  		
  		$.getJSON("/vipCenter/userPointExtTransfer.do",param,function(data){
  			var loginError = data.loginError;
  			var success = data.success;
  			var message = data.message;
  			var toUrl = data.toUrl;
  			
  			if(loginError == 1){
  				var tips=new Dialog({
  				  type:"confirm",
  				  text:"系统提示",
  				  tipsText:msg,
  				  buttonSureText:"去登陆", 
  				  buttonCancelText:"关闭", 
  				  callBack:function(){         //回调函数
  					  window.location.href=toUrl;
  				  },
  				  mask:0.8,
  				  isDrag:true                //开起拖动
  				});
  			}else if(success == 0){
  				var tips=new Dialog({
    				  type:"alert",
    				  text:"系统提示",
    				  tipsText:message,
    				  buttonCancelText:"关闭", 
    				  mask:0.8,
    				  isDrag:true                //开起拖动
				});
  			}else if(success == 1){
  				var tips=new Dialog({
  				  type:"alert",
  				  text:"系统提示",
  				  tipsText:message,
  				  buttonCancelText:"关闭", 
  				  mask:0.8,
  				  isDrag:true                //开起拖动
				});
  			}
  		});
	});
	
	$('#moneySubmit').bind('click',function(event){
  		var changeAmount = $('#integration').val();
  		var param = {};
  		param['amount'] = changeAmount;
  		
  		$.getJSON("/userEmoneyTransfer.do",param,function(data){
  			var loginError = data.loginError;
  			var success = data.success;
  			var message = data.message;
  			var toUrl = data.toUrl;
  			
  			if(loginError == 1){
  				var tips=new Dialog({
  				  type:"confirm",
  				  text:"系统提示",
  				  tipsText:msg,
  				  buttonSureText:"去登陆", 
  				  buttonCancelText:"关闭", 
  				  callBack:function(){         //回调函数
  					  window.location.href=toUrl;
  				  },
  				  mask:0.8,
  				  isDrag:true                //开起拖动
  				});
  			}else if(success == 0){
  				var tips=new Dialog({
    				  type:"alert",
    				  text:"系统提示",
    				  tipsText:message,
    				  buttonCancelText:"关闭", 
    				  mask:0.8,
    				  isDrag:true                //开起拖动
				});
  			}else if(success == 1){
  				var tips=new Dialog({
  				  type:"alert",
  				  text:"系统提示",
  				  tipsText:message,
  				  buttonCancelText:"关闭", 
  				  mask:0.8,
  				  isDrag:true                //开起拖动
				});
  			}
  		});
	});
	
	
	$('#integrationSubmit2').bind('click',function(event){
  		var changeAmount = $('#integration').val();
		var targetLoginId = $('#targetLoginId').val();
  		var param = {};
  		param['amount'] = changeAmount;
  		param['targetLoginId'] = targetLoginId;
  		
  		$.getJSON("/vipCenter/userPointTransfer2.do",param,function(data){
  			var loginError = data.loginError;
  			var success = data.success;
  			var message = data.message;
  			var toUrl = data.toUrl;
  			
  			if(loginError == 1){
  				var tips=new Dialog({
  				  type:"confirm",
  				  text:"系统提示",
  				  tipsText:msg,
  				  buttonSureText:"去登陆", 
  				  buttonCancelText:"关闭", 
  				  callBack:function(){         //回调函数
  					  window.location.href=toUrl;
  				  },
  				  mask:0.8,
  				  isDrag:true                //开起拖动
  				});
  			}else if(success == 0){
  				var tips=new Dialog({
    				  type:"alert",
    				  text:"系统提示",
    				  tipsText:message,
    				  buttonCancelText:"关闭", 
    				  mask:0.8,
    				  isDrag:true                //开起拖动
				});
  			}else if(success == 1){
  				var tips=new Dialog({
  				  type:"alert",
  				  text:"系统提示",
  				  tipsText:message,
  				  buttonCancelText:"关闭", 
  				  mask:0.8,
  				  isDrag:true                //开起拖动
				});
  			}
  		});
	});
});